//
//  HttpClient.h
//  MaiJianBaseProject
//
//  Created by Michael Fan on 14-7-9.
//  Copyright (c) 2014年 Michael Fan. All rights reserved.
//
/*
 http通讯--
 get--post--mulpost(developing)--download(developing)
 设置http-header
 设置请求超时时间
 设置接收数据格式-json/xml
 统一的请求失败错误处理。
 */

#import "QiniuSDK.h"

#define requestDataKey    @"results"

#define requestAPI @"/apimd"
#import "AFHTTPRequestOperationManager.h"
#import "UIKit+AFNetworking.h"

//#define request_OSAPPV  [NSString stringWithFormat:@"os=ios&appv=%@",gApp.selfapp_Version]
#define kErrorInt   -1

#define kHttpRequestTimeOutInterval  10

#define serverUrl @"http://api.mingyizhudao.com"

enum
{
    STATE_SUCCESS = 0,
};

@interface HttpClient : AFHTTPRequestOperationManager


- (AFHTTPRequestOperation *)GET:(NSString *)URLString
                     parameters:(id)parameters
                        success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
                        failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;

- (AFHTTPRequestOperation *)POSTOTHER:(NSString *)URLString
                      parameters:(id)parameters
                         success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
                         failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;

- (void)POST:(NSString *)URLString
         parameters:(id)parameters
            success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
            failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;

- (AFHTTPRequestOperation*)PUT:(NSString *)URLString
                     parameters:(id)parameters
                        success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
                        failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;

//上传图片
- (AFHTTPRequestOperation *)UPLOADIMAGE:(NSString *)URLString
                            uploadImage:(UIImage *)image
                        uploadImageName:(NSString *)imageName
                             parameters:(id)parameters
                                success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
                                failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;

//七牛上传
- (void)UPLOADIMAGEQINIU:(NSString *)URLString
             uploadImage:(UIImage *)image
         uploadImageName:(NSString *)imageName
              parameters:(id)parameters
                 success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
                 failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;

/*
- (AFHTTPRequestOperation *)UPLOAD:(NSString *)URLString
                     dataUploadAry:(NSMutableArray *)dataUpLoadAry
                        parameters:(id)parameters
                           success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
                           failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;

//下载到指定文件路径
- (AFHTTPRequestOperation *)DOWNLOAD:(NSString *)URLString
                            filePath:(NSString *)filePaht
                          parameters:(id)parameters
                            progress:(void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))progress
                             success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
                             failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;

//下载到内存
- (AFHTTPRequestOperation *)DOWNLOAD:(NSString *)URLString
                          parameters:(id)parameters
                            progress:(void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))progress
                             success:(void (^)(AFHTTPRequestOperation *operation, id responseObject, NSData *finishData))success
                             failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
 
 */

@end
